package org.example.day;

import java.util.HashMap;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/08/14 10:38
 */
public class Solution3152 {

    public static void main(String[] args) {
        new Solution3152().isArraySpecial(new int[]{1}, new int[][]{{0, 0}});
    }

    public boolean[] isArraySpecial(int[] nums, int[][] queries) {
        boolean[] res = new boolean[queries.length];
        HashMap<Integer, Integer> map = new HashMap<>();

        int startIndex = 0;
        int sum = 1;
        map.put(0, 0);
        boolean flag = nums[0]%2==0;
        for (int i = 1; i < nums.length; i++) {
            map.put(i, 0);
            if(sum % 2 == 0 && ((nums[i]%2==0) == flag)){
               sum++;
            } else if (sum % 2 != 0 && ((nums[i]%2==0) != flag)) {
               sum++;
            }else {
               for(int j=startIndex;j<i;j++){
                   map.put(j, i-j-1);
               }
               sum = 1;
               startIndex = i;
               flag = nums[i]%2==0;
            }
        }

        if(sum > 1){
            for(int j=startIndex;j<nums.length;j++){
                map.put(j, nums.length-j-1);
            }
        }

        for (int i = 0; i < queries.length; i++) {
            res[i] = (map.get(queries[i][0]) + queries[i][0]) >= queries[i][1];
            System.out.println(res[i]);
        }

        return res;
    }

}
